<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>js继承</title>
		<script>
			class Animal{
				//构造方法
				constructor(name,age){
					this.name=name;
					this.age=age;
				}
				
				showSelf(){
					alert("这个动物叫"+this.name+",年龄是"+this.age+"岁了");
				}
			}
			class Dog extends Animal{
				constructor(name="无名小狗",age=1,type="中华田园犬"){
					super(name,age);
					this.type=type;
				}
				// constructor(){
				// 	super("无名小狗",1);
				// 	this.type="中华田园犬";
				// }
				showSelf(){
					super.showSelf();
					alert("类别是"+this.type);
				}
				catchMouse(name){
					alert(this.name+"抓住了"+name);
				}
			}
			//var an=new Animal("青蛙",2);
			//an.showSelf();
			//var d=new Dog("大黄",3,"狼狗");
			var d=new Dog();

			d.showSelf();
			d.catchMouse("老鼠jerry");
		</script>
	</head>
	<body>
	</body>
</html>